﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Echart</title>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5.4.0/dist/echarts.min.js"></script>
</head>
<body>
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));

        // 指定图表的配置项和数据
        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            grid: {
                top: '10%',
                left: '10%',
                right: '10%',
                bottom: '10%',
                containLabel: true
            },
            xAxis: {
                show: true,
                axisLabel: {
                    formatter: '{value} 位',
                    show: true
                },
                splitLine: { show: false },
                axisLine: {
                    show: true
                }
            },
            yAxis: {
                type: 'category',
                inverse: true, // 倒叙
                axisLabel: {
                    color: '#1E90FF',
                    formatter: (val) => {
                        return `${val}`;
                    }
                },
                axisLine: {
                    show: false // 轴线
                },
                axisTick: {
                    show: false // 刻度线
                },
                data: ['一级', '二级', '三级', '四级', '五级']
            },
            series: [
                {
                    name: 'Echarts',
                    type: 'bar',
                    barWidth: 10,
                    showBackground: true,
                    barMaxWidth: 20,
                    barMinWidth: 5,
                    itemStyle: {
                        borderRadius: [0, 10, 10, 0],
                        color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
                            { offset: 0, color: 'rgba(183, 75, 238)' },
                            { offset: 1, color: 'rgba(50, 229, 255, 1)' }
                        ]),
                        borderWidth: 1,
                        borderColor: "black"
                    },
                    data: [100, 200, 300, 400, 500]
                }
            ]
        };


        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>
</html>
